package com.caiyigo.baihua.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Repository;

import com.caiyigo.baihua.dto.KaoshicjDto;
import com.caiyigo.baihua.dto.KaoshikemuDto;
import com.caiyigo.baihua.dto.KaoshizwDto;
import com.caiyigo.baihua.dto.KaoshizwDto;
import com.caiyigo.baihua.dto.ZykmDto;
import com.caiyigo.baihua.model.Kaoshikemu;
import com.caiyigo.baihua.model.Kaoshizw;
import com.caiyigo.baihua.model.Zykm;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;

/**
 * @author Administrator
 * 
 */
@Repository
public class ZykmMapperSql implements ZykmMapper {
	private SqlSessionFactory sqlSessionFactory;

	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
		this.sqlSessionFactory = sqlSessionFactory;
	}

	public List selectForCombox(ZykmDto dto, PageBounds pageBounds) {

		Map<String, Object> params = new HashMap<String, Object>();

		if (!StringUtils.isEmpty(dto.getZymc())) {
			params.put(ZykmDto.FileConstant.zymc, dto.getZymc());
		}

		List<Object> list = null;
		SqlSession session = sqlSessionFactory.openSession();
		try {
			list = session.selectList(
					"com.caiyigo.baihua.dao.ZykmMapper.selectForCombox",
					params, pageBounds);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.close();
		}

		return list;
	}
	public List selectKemuByZyid(ZykmDto dto, PageBounds pageBounds) {

		Map<String, Object> params = new HashMap<String, Object>();

		if (!StringUtils.isEmpty(dto.getZyid())) {
			params.put(ZykmDto.FileConstant.zyid, dto.getZyid());
		}

		List<Object> list = null;
		SqlSession session = sqlSessionFactory.openSession();
		try {
			list = session.selectList(
					"com.caiyigo.baihua.dao.ZykmMapper.selectKemuByZyid",
					params, pageBounds);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.close();
		}

		return list;
	}
	@Override
	public int deleteByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insert(Zykm record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insertSelective(Zykm record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Zykm selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(Zykm record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKey(Zykm record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<ZykmDto> selectByPid(Integer pid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ZykmDto> selectByPidIsNull() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ZykmDto> listBySeq() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int deleteByPid(Integer pid) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Zykm isExistSon(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List selectKemu(String zyid, Kaoshikemu dto, PageBounds pageBounds) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("zyid", zyid);
		if (!StringUtils.isEmpty(dto.getKmMc())) {
			params.put(KaoshikemuDto.FileConstant.kmMc, dto.getKmMc());
		}
		if (!StringUtils.isEmpty(dto.getKmDm())) {
			params.put(KaoshikemuDto.FileConstant.kmDm, dto.getKmDm());
		}
		List<Object> list = null;
		SqlSession session = sqlSessionFactory.openSession();
		try {
			list = session.selectList(
					"com.caiyigo.baihua.dao.ZykmMapper.selectKemu", params,
					pageBounds);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			session.close();
		}

		return list;
	}

	@Override
	public List<ZykmDto> selectKemuByZyid(ZykmDto dto) {
		// TODO Auto-generated method stub
		return null;
	}

}